package org.jeecg.board.mapper;

import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.jeecg.board.dto.BoardDataDTO;
import org.jeecg.board.dto.LineBoardBarDTO;
import org.jeecg.board.dto.QisBoardDataDTO;
import org.jeecg.board.dto.UnhealthyBoardDataDTO;
import org.jeecg.trace.entity.MesUnitStatus;

import java.util.List;
import java.util.Map;

/**
 * &#064;Description
 * &#064;Author  LiCY
 * &#064;Date  2023/4/25
 */
@Mapper
public interface LineBoardMapper {
    /**
     * 计算工站一次合格率
     */
    List<LineBoardBarDTO> getStnFTQ(@Param("param") Map<String, Object> map);

    /**
     * 计算工站OEE
     *
     * @param map
     * @return
     */
    List<LineBoardBarDTO> getStnOEE(@Param("param") Map<String, Object> map);

    /**
     * 计算产线各工站时间稼动率
     */
    List<LineBoardBarDTO> getAvailability(@Param("param") Map<String, Object> map);

    /**
     * 计算产线各工站性能稼动率
     */
    List<LineBoardBarDTO> getPerformance(@Param("param") Map<String, Object> map);

    /**
     * 计算当日产线生产总数
     */
    Double getTotalNum(@Param("param") Map<String, Object> map);

    /**
     * 计算当日产线不合格总数
     */
    Double getNGNum(@Param("param") Map<String, Object> map);

    /**
     * 计算工单合格率
     */
    Double getWoPassRate(@Param("param") Map<String, Object> map);

    /**
     * 计算工单合格率
     */
    Integer getWoErrorNum(@Param("param") Map<String, Object> map);

    /**
     * 计算指定工站总生产数
     * @param map
     * @return
     */
    Integer getOpTotalNum(@Param("param") Map<String, Object> map,@Param("list") List<String> opList);

    /**
     * 计算指定工站不合格数
     * @param map
     * @return
     */
    List<String> getOpErrorNum(@Param("param") Map<String, Object> map,@Param("list") List<String> opList);

    List<String> getTimeList(@Param("param") Map<String, Object> param);
    @InterceptorIgnore(tenantLine ="true")
    List<Integer> getPlanNum(@Param("param") Map<String, Object> param);
    @InterceptorIgnore(tenantLine ="true")
    List<Integer> getActualNum(@Param("param") Map<String, Object> param);

    Double getTodayDowntime(@Param("param") Map<String, Object> param);

    Double getTodayDowntime2(@Param("param") Map<String, Object> param);

    Double getLineAvailability(@Param("param") Map<String, Object> param);

    Double getTotalRunningTime(@Param("param") Map<String, Object> param);
    Double getTotalTime(@Param("param") Map<String, Object> param);
    Double getTotalRunningTimeForCurrentMonth(@Param("param") Map<String, Object> param);
    Double getTotalStopTimeForCurrentMonth(@Param("param") Map<String, Object> param);
    Double getTotalRunningTimeForCurrentDay(@Param("param") Map<String, Object> param);

    Double getTotalStopTimeForCurrentDay(@Param("param") Map<String, Object> param);

    Double getLinePerformance(@Param("param") Map<String, Object> param);

    Double getTodayQualifiedNum(@Param("param") Map<String, Object> param);

    Double getTodayUnqualifiedNum(@Param("param") Map<String, Object> param);

    List<LineBoardBarDTO> getUnqualifiedCause(@Param("param") Map<String, Object> param);

    List<LineBoardBarDTO> getAlarmDuration(@Param("param") Map<String, Object> param);

    List<LineBoardBarDTO> getAlarmNum(@Param("param") Map<String, Object> param);

    Integer getWoidNum(@Param("param") Map<String, Object> param);

    Integer getOpNum();

    Integer getCtNum(@Param("param") Map<String, Object> param);

    String getFgOp(@Param("param") Map<String, Object> param);

    String getFirstOp(@Param("param") Map<String, Object> param);
    /**
     * 求班组理论小时累计生产数
     */
    @InterceptorIgnore(tenantLine ="true")
    List<Integer> getClassPlanTotalNum(@Param("param") Map<String, Object> param);


    /**
     * 求班组理论小时累计生产数
     */
    @InterceptorIgnore(tenantLine ="true")
    List<Integer> getClassAlarmTotalNum(@Param("param") Map<String, Object> param);
    @InterceptorIgnore(tenantLine ="true")
    List<String> getClassTimeList(@Param("param") Map<String, Object> param);
    @InterceptorIgnore(tenantLine ="true")
    List<String> getDayTimeList(@Param("param") Map<String, Object> param);

    List<Integer> getOpPassRate(@Param("param") Map<String, Object> param,@Param("op")String op);

    List<String> getLineOPList(@Param("param") Map<String, Object> param);

    List<Double> getLineOPRunList(@Param("param") Map<String, Object> param);

    List<String> getLineOPStopList(@Param("param") Map<String, Object> param);

    Integer getProductBeat(@Param("param") Map<String, Object> param);

    /**
     * 查询产线最近10条报警日志
     * @param param
     * @return
     */
    List<BoardDataDTO> getLineWarnLogList(@Param("param") Map<String, Object> param);
    /**
     * 查询已包装数量
     * @param param
     * @return
     */
    Integer getPackedQty(@Param("param") Map<String, Object> param);
    /**
     * 查询待拍X光数
     * @param param
     * @return
     */
    Integer getXRayQty(@Param("param") Map<String, Object> param);
    /**
     * 查询成品报废数
     * @param param
     * @return
     */
    Integer getProductScrapQty(@Param("param") Map<String, Object> param);
    /**
     * 查询半成品报废数
     * @param param
     * @return
     */
    Integer getSemiManufacturedScrapQty(@Param("param") Map<String, Object> param);
    /**
     * 查询产品良品，总数，报废数
     * @param param
     * @return
     */
    Integer getPartNoSomeQty(@Param("param") Map<String, Object> param);

    /**
     * 获取产线质量7日内样件点检数据
     * @param param
     * @return
     */
    List<BoardDataDTO> getIndividuallyListByLine(@Param("param") Map<String, Object> param);

    /**
     * 获取产线最近10条设备报警数据
     * @param param
     * @return
     */
    List<BoardDataDTO> getEquipmentAlarmsByLine(@Param("param") Map<String, Object> param);
    /**
     * 获取产线生产数据
     * @param param
     * @return
     */
    List<MesUnitStatus> getProductionDataByLine(@Param("param")  Map<String, Object> param, @Param("typ")String typ);

    List<UnhealthyBoardDataDTO> getMonthUnhealthyByLine(@Param("param")Map<String, Object> param,@Param("typ") String typ);

    List<BoardDataDTO> getShiftOpUnhealthyList(@Param("param")Map<String, Object> param);

    Integer getLinePackTotal(@Param("param")Map<String, Object> param,@Param("typ") String typ);

    QisBoardDataDTO getLineProductScrapTotal(@Param("param")Map<String, Object> param,@Param("typ") String typ);

    QisBoardDataDTO getLineXRayTotal(@Param("param")Map<String, Object> param,@Param("typ") String typ);

    Integer getDayStartTime();

    Integer getLineProductTotal(Map<String, Object> param,@Param("typ") String month);

    Double getLineBottleneckDowntime(String string);

    /**
     * 获取当前产品编号
     * @return
     */
    String getNowPartNo();
    /**
     * 获取产线名称
     */
    String getLineName();

    String getBottleneck();

    List<LineBoardBarDTO> getYUnqualifiedCause(@Param("param")Map<String, Object> param);

    List<LineBoardBarDTO> getYAlarmDuration(@Param("param")Map<String, Object> param);

    List<LineBoardBarDTO> getYAlarmNum(@Param("param")Map<String, Object> param);
}
